#include"timeStamp.h"
#include"public.h"

#include<ctime>
#include<iostream>

TimeStamp::TimeStamp():secondSinceEpoch_(0)
{

}
TimeStamp::TimeStamp(int64_t secondSinceEpoch):secondSinceEpoch_(secondSinceEpoch)
{

}
std::string TimeStamp::ToString() const
{
   
   struct tm localtime;
   localtime_r(&secondSinceEpoch_,&localtime);
   char buff[SMALL_BUF_LEN]; //
   snprintf(buff,SMALL_BUF_LEN,"[%04d / %02d / %02d/%02d: %02d : %02d]",localtime.tm_year + 1900,localtime.tm_mon + 1,localtime.tm_mday,localtime.tm_hour,localtime.tm_min,localtime.tm_sec);
   return buff;
}
TimeStamp TimeStamp:: Now()
{
   return TimeStamp(time(NULL));
} 
